package edu.zju.gis.dbfg.server.controller;

import edu.zju.gis.dbfg.common.Result;
import edu.zju.gis.dbfg.common.base.BaseController;
import edu.zju.gis.dbfg.common.util.FileUtil;
import edu.zju.gis.dbfg.server.model.MapData;
import edu.zju.gis.dbfg.server.model.search.UserSearch;
import edu.zju.gis.dbfg.server.service.MapDataService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@CrossOrigin
@Controller
@RequestMapping("/mapdata")
public class MapDataController extends BaseController<MapData, MapDataService, String, UserSearch>{
    @RequestMapping(value = "/select", method = RequestMethod.POST)
    @ResponseBody
    //public Result get(@RequestParam("id") String id) throws IOException {
        public Result getdd(@RequestBody MapData mapdata) throws IOException {
        List<String> lines=FileUtil.readByLine(service.select(mapdata.getId()).getRoute(),100,false);
        //String productList = JSON.toJSONString(lines);
       //HttpServletRequest request = ServletActionContext.getRequest();
//        String word = request.getParameter("word");
//        System.out.println(word);
        return Result.success().setBody(lines);
    }
}
